package zl.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import zl.bean.Admin;

import zl.mapper.AdminMapper;
import zl.service.AdminService;

import java.util.List;

@Service
public class AdminServiceImpl implements AdminService {
    @Autowired
    private AdminMapper adminMapper;
    @Override
    public int addAdmin(Admin admin) {
        Admin u = adminMapper.selectByUsername(admin.getUsername());
        if(u==null){
            return adminMapper.addAdmin(admin);
        }else {
            return 3;
        }
    }

    @Override
    public int deleteAdmin(Integer id) {
        return adminMapper.deleteAdmin(id);
    }

    @Override
    public int updateAdmin(Admin admin) {
        return adminMapper.updateAdmin(admin);
    }

    @Override
    public List<Admin> selectAllAdmin() {
        return adminMapper.selectAllAdmin();
    }

    @Override
    public Admin selectById(Integer id) {
        return adminMapper.selectById(id);
    }
}
